package com.yugao.fintech.antelope.shop.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yugao.fintech.antelope.base.ram.ActionType;
import com.yugao.fintech.antelope.base.ram.RamResource;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutDetailPageReq;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutDetailResp;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutDetailSaveReq;
import com.yugao.fintech.antelope.shop.model.rqrs.sku.SkuStockInOutDetailUpdateReq;
import com.yugao.fintech.antelope.shop.service.SkuStockInOutDetailService;
import com.yugao.fintech.framework.core.response.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 出入库明细
 * 

 */
@Api(tags = "出入库明细")
@RestController
@RequestMapping("/skuStockInOut/detail")
public class SkuStockInOutDetailController {
    @Autowired
    private SkuStockInOutDetailService skuStockInOutDetailService;

    @ApiOperation(value = "分页出入库明细")
    @GetMapping("/page")
    @RamResource(action = "shopGoods:skuStockInOutDetail:query", name = "查询出入库详情", type = ActionType.READ)
    public Resp<IPage<SkuStockInOutDetailResp>> pageDetail(@Validated SkuStockInOutDetailPageReq req) {
        return Resp.ok(skuStockInOutDetailService.pageDetail(req));
    }

    @ApiOperation(value = "通过id查找出入库明细")
    @GetMapping("/get")
    @RamResource(action = "shopGoods:skuStockInOutDetail:query", name = "查询出入库详情", type = ActionType.READ)
    public Resp<SkuStockInOutDetailResp> getDetail(@RequestParam(value = "id") Long id) {
        return Resp.ok(skuStockInOutDetailService.getDetail(id));
    }
  
    @ApiOperation(value = "保存出入库明细")
    @PostMapping("/save")
    @RamResource(action = "shopGoods:skuStockInOutDetail:save", name = "保存出入库详情", type = ActionType.WRITE)
    public Resp<?> saveDetail(@Validated @RequestBody SkuStockInOutDetailSaveReq req) {
        return Resp.ok(skuStockInOutDetailService.saveDetail(req));
    }
  
    @ApiOperation(value = "更新出入库明细")
    @PostMapping("/update")
    @RamResource(action = "shopGoods:skuStockInOutDetail:update", name = "更新出入库详情", type = ActionType.WRITE)
    public Resp<?> updateDetail(@Validated @RequestBody SkuStockInOutDetailUpdateReq req) {
        return Resp.ok(skuStockInOutDetailService.updateDetail(req));
    }
  
    @ApiOperation(value = "批量删除出入库明细")
    @DeleteMapping("/batchDelete")
    @RamResource(action = "shopGoods:skuStockInOutDetail:delete", name = "删除出入库详情", type = ActionType.WRITE)
    public Resp<?> batchDeleteDetail(@RequestParam(value = "ids") List<Long> ids) {
        return Resp.ok(skuStockInOutDetailService.batchDeleteDetail(ids));
    }
  
    @ApiOperation(value = "删除出入库明细")
    @DeleteMapping("/delete")
    @RamResource(action = "shopGoods:skuStockInOutDetail:delete", name = "删除出入库详情", type = ActionType.WRITE)
    public Resp<?> deleteDetail(@RequestParam(value = "id") Long id) {
        return Resp.ok(skuStockInOutDetailService.deleteDetail(id));
    }
}
